<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li
      v-for="item in arr"
      :key="item.id"
      :class="{ completed: item.isDone }"
    >
      <div class="view">
        <input
          class="toggle"
          type="checkbox"
          v-model="item.isDone"
        />
        <label>{{ item.name }}</label>
        <button
          class="destroy"
          @click="destroyBtn(item.id)"
        ></button>
      </div>
    </li>
  </ul>

</template>

<script>
export default {
  // 接收父组件的数据
  props: ["arr"],
  methods: {
    destroyBtn(id) {
      // console.log("点击了删除按钮", id);
      this.$emit('del',id)
    },
  },
};
</script>